import { createBrowserRouter } from "react-router-dom";
import AdminLayout from "@/page/Admin/Layout";
import Course from "@/page/Admin/Course";
import Business from "@/page/Admin/Business";
import CoachLayout from "@/page/Coach/Layout";
import Register from "@/page/Student/Register";
import StudentLayout from "@/page/Student/Layout";
import Application from "@/page/Admin/Application";
import CoachInformation from "@/page/Admin/CoachInformation";
import CarManagement from "@/page/Admin/CarManagement";
import CoachAccount from "@/page/Admin/CoachAccount";
import Login from "@/page/Login";
import Accept from "@/page/Coach/Accept";
import Grade from"@/page/Coach/Grade";
import Attendance from "@/page/Coach/Attendance";
import TeachPlan from "@/page/Coach/TeachPlan";
import ChangeSchedule from "@/page/Student/ChangeSchedule";
import LearningProcess from "@/page/Student/LearningProcess";
import Exam from "@/page/Student/Exam";
import StudentAccount from "@/page/Admin/StudentAccount";
import StudentInformation from "@/page/Admin/StudengInformation";
import StudentLearningProcess from "@/page/Admin/StudentLearnProcess";
import PermissionAllocation from "@/page/Admin/PermissionAllocation"
import { AuthRoute } from "@/components/AuthRoute";
import { Suspense } from "react";
import ForgetPassword from "@/page/ForgetPassword";

 const router = createBrowserRouter([
    {
        path:'/',
        element:<Login/>
    },
    {
        path:'/forgetPassword',
        element:<ForgetPassword/>
    },
    {
        path:'/admin',
        element:<AuthRoute><AdminLayout/></AuthRoute>,
        children:[
            {
                index:true,
                element:<Suspense fallback={'加载中'}><Course/></Suspense>
            },
            {
                path:'business',
                element:<Suspense fallback={'加载中'}><Business/></Suspense>
            },
            {
                path:'application',
                element:<Suspense fallback={'加载中'}><Application/></Suspense>
            },
            {
                path:'coachInformation',
                element:<Suspense fallback={'加载中'}><CoachInformation/></Suspense>
            },
            {
                path:'carManagement',
                element:<Suspense fallback={'加载中'}><CarManagement/></Suspense>
            },
            {
                path:'coachAccount',
                element:<Suspense fallback={'加载中'}><CoachAccount/></Suspense>
            },
            {
                path:'studentAccount',
                element:<Suspense fallback={'加载中'}><StudentAccount/></Suspense>
            },
            {
                path:'studentInformation',
                element:<Suspense fallback={'加载中'}><StudentInformation/></Suspense>
            },
            {
                path:'permissionAllocation',
                element:<Suspense fallback={'加载中'}><PermissionAllocation/></Suspense>
            },
            {
                path:'studentLearningProcess',
                element:<Suspense fallback={'加载中'}><StudentLearningProcess/></Suspense>
            }
        ]
    },
    {
        path:'/coach',
        element:<AuthRoute><CoachLayout/></AuthRoute>,
        children:[
            {
                index:true,
                element:<Suspense fallback={'加载中'}><Accept/></Suspense>
            },
            {
                path:'grade',
                element:<Suspense fallback={'加载中'}><Grade/></Suspense>
            },
            {
                path:'attendance',
                element:<Suspense fallback={'加载中'}><Attendance/></Suspense>
            },
            {
                path:'teachplan',
                element:<Suspense fallback={'加载中'}><TeachPlan/></Suspense>
            }
        ]
    },
    {
        path:'/student',
        element:<AuthRoute><StudentLayout/></AuthRoute>,
        children:[
            {
                index:true,
                element:<Suspense fallback={'加载中'}><Register/></Suspense>
            },
            {
                path:'changeschedule',
                element:<Suspense fallback={'加载中'}><ChangeSchedule/></Suspense>
            },
            {
                path:'learningprocess',
                element:<Suspense fallback={'加载中'}><LearningProcess/></Suspense>
            },
            {
                path:'exam',
                element:<Suspense fallback={'加载中'}><Exam/></Suspense>
            }
        ]
    }
])

export default router